Implementation of JTA transactions with Tyrex integrated hibernate and JDBC in unmanaged environmentsThe recent integration of hibernate into the company's products, the company's products using Tyrex to provide JTA transaction support, its own based on JDBC implementation of a set of O/R Mapping, and embedded tomcat, so the transaction part of its own implementation, and Tomcat's environment, independent o
. 4.0.6 is the most recommended release version in the first stage. The built-in database connection pool is Tyrex 0.9.7.0 and Tyrex is developed by exolab.org. For more information, see www. exolab.org. Later, Tomcat developers reconstructed Tomcat on the basis of 4.0.x, And the reconstructed release version recommended 4.1.18. At this time, the built-in connection pool was changed to DBCP, which is also a
so on.4. The implementation of TransactionManager can handle multiple xaresouce (a xaresouce list).Like Tyrex. or transaction implementation code for EJB server such as JBossNote: The XA:XA protocol was first proposed by Tuxedo and presented to the X/open organization as the interface standard for the Resource Manager (database) and transaction manager. Currently, major database manufacturers such as Oracle, Informix, DB2, and Sybase provide support
to perform all the Undo operations based on the data operation log, or recover the data backup.Some databases generate a "reverse operation" log when performing data operations. For example, insert to delete.
Global transaction requires support for XA interfaces (including in JTA.
Import javax. SQL. xaconnection;Import javax. transaction. Xa. Xid;Import javax. transaction. Xa. xaresource;Import javax. transaction. Xa. xaexception;Import javax. transaction. transaction;Import javax. trans
provides the implementation of XA.
Oracle, Sybase, DB2, SQL Server, and other large databases support XA
The free Postresql also supports XAMy SQL does not support the local transaction, let alone the global transation.
The implementation of TransactionManager can handle multiple xaresouce (a xaresouce list).Like Tyrex. or the transaction implementation code of an EJB server such as JBoss
Reproduced below a detailed analysis of the principle of XA
transaction, let alone the global transation.
3. XA requires two stages of submission-prepare and commit.
Suppose there are two connection, Con1, Con2, the general process is as follows,
Con1 = Xaresouce1.getconnection ...
Con2 = Xaresouce2.getconnection ...
Con1 do some thing.
Con2 do some thing.
After they finish.
Pre1 = Xaresouce1.prepare ();
Pre2 = Xaresouce2.prepare ();
if (both Pre1 and Pre2 are OK) {
XAResouce1 and 2 commits
}else {
XAResouce1 and 2 rollback
}
It was said ear
requires two-phase commit: prepare and commit.Assume there are two connections, con1, con2. The general process is as follows,
Con1 = xaresouce1.getconnection...Con2 = xaresouce2.getconnection...
Con1 do some thing.Con2 do some thing.After they finish.
Pre1 = xaresouce1.prepare ();Pre2 = xaresouce2.prepare ();
If (both pre1 and pre2 are OK ){Xaresouce1 and 2 commit} Else {Xaresouce1 and 2 rollback}
As mentioned above, when xaresouce1 and 2 commit,Maybe xaresouce1 commit () is successful, and xa
, Xaresouce.recover () or something like that. But in general, there is no other way, it is necessary for the data administrator to undo all operations according to the data operation log, or to restore the data backup. Some databases generate an "Anti-action" log when they perform data operations. For example, insert to delete, and so on. The Global Transaction requires support for the XA interface (including in JTA). Import javax.sql.XAConnection; Import Javax.transaction.xa.Xid; Import Javax.
the time of XAResouce1 and 2 commit,Perhaps XAResouce1 commit () succeeded, XAResouce2 commit () failed.At this point, a "heuristic exception" is thrown. The program can handle this exception. For example, Xaresouce.recover () or something like that.But in general, there is no other way, it is necessary for the data administrator to undo all operations according to the data operation log, or to restore the data backup.Some databases generate an "Anti-action" log when they perform data operation
J2ee
Enterprise Application system based on Java EE-tools list Application Server--------------------------------jetty-http://jetty.mortbay.org/jetty/index.html HTTP Server and Java Serverlet container jotm-http://www.objectweb.org/jotm/index.html Transaction Management Server apache-http://www.apache.org/These things don't go off, http , XML, Ant, Tomcat, Velocity, ... The soul of enterprise application. tyrex-http://tyrex.sf.net/Transaction Manageme
Contact Us
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.